angular.module('fs.waf').controller('poi.demo.fsTimeController', [
  '$scope',
  '$q',
  function($scope, $q) {
    var ctrl = this;

    ctrl.ngModel = {
      timeValue: new Date()
    };

    ctrl.layoutConfig = {
      demo: {
        name: 'demo',
        gridGroups: [
          {
            grids: ['edit', 'readonly', 'view']
          },
          {
            grids: ['vm_options']
          }
        ],
        gridConfigs: {
          valueText: {
            name: 'text',
            label: 'value',
            size: 2,
            type: 'text',
            model: 'textValue',
            appScope: $scope,
            showStyle: 'edit',
            tooltip: 'value'
          },
          displayText: {
            name: 'text',
            label: 'display',
            size: 2,
            type: 'text',
            model: 'displayText',
            appScope: $scope,
            showStyle: 'edit',
            tooltip: 'display',
            uppercase: false
          },
          changeData: {
            name: 'button',
            label: 'changeData',
            size: 2,
            type: 'button',
            appScope: $scope,
            text: 'button',
            tooltip: 'button tooltip',
            options: {
              icon: 'setup',
              showIcon: false,
              callback: {
                click: 'vm.changeData'
              }
              // hotKey: 'alt+1'
            }
          },
          edit: {
            name: 'time',
            label: 'edit',
            size: 4,
            type: 'time',
            model: 'timeValue',
            appScope: $scope,
            showStyle: 'edit',
            tooltip: 'time tooltip',
            options: {
              showSeconds: true,
              isMeridian: true
            }
          },
          readonly: {
            name: 'time',
            label: 'readonly',
            size: 4,
            type: 'time',
            model: 'timeValue',
            appScope: $scope,
            showStyle: 'readonly',
            tooltip: 'time tooltip',
            options: {
              showSeconds: true,
              isMeridian: true
            }
          },
          view: {
            name: 'time',
            label: 'view',
            size: 4,
            type: 'time',
            model: 'timeValue',
            appScope: $scope,
            showStyle: 'view',
            tooltip: 'time tooltip',
            options: {
              showSeconds: true,
              isMeridian: true
            }
          },
          vm_options: {
            name: 'time',
            label: 'vm_options',
            size: 4,
            type: 'time',
            model: 'timeValue',
            appScope: $scope,
            showStyle: 'edit',
            tooltip: 'time tooltip',
            options: 'vm.options'
          }
        }
      }
    };

    ctrl.options = {
      isMeridian: false,
      showSeconds: true
    };

    ctrl.normalData = [
      {
        value: 123,
        display: 'Jack'
      },
      {
        value: 456,
        display: 'Lee'
      },
      {
        value: 1231,
        display: 'Jack1'
      },
      {
        value: 4561,
        display: 'Lee1'
      },
      {
        value: 1232,
        display: 'Jack2'
      },
      {
        value: 4562,
        display: 'Lee2'
      }
    ];

    ctrl.componentStyle = [
      {
        value: 'edit',
        display: 'edit'
      },
      {
        value: 'readonly',
        display: 'readonly'
      },
      {
        value: 'view',
        display: 'view'
      }
    ];

    ctrl.changeData = function() {
      if (ctrl.ngModel.textValue && ctrl.ngModel.displayText) {
        ctrl.normalData.push({
          value: ctrl.ngModel.textValue,
          display: ctrl.ngModel.displayText
        });
      }
    };

    ctrl.clickFun = function() {
      console.log(ctrl.ngModel.linkValue);
    };
  }
]);
